#include "dialog.h"
#include "QPainter"
#include "QTime"
void Dialog::timerEvent(QTimerEvent *)
{
    int i;
    for(i=0;i<10;i++)m[i]=m[i+1];
    m[10]=rand()%300;
    this->repaint();
}




Dialog::Dialog(QWidget *parent)
    : QDialog(parent)
{
    int j;
    for(j=0;j<11;j++)m[j]=qrand()%300;
    this->startTimer(45);
}




Dialog::~Dialog()
{
}



void Dialog::paintEvent(QPaintEvent *)
{
    int j;
    QPainter painter(this);
    QPen pen(Qt::SolidLine);
    painter.setPen(pen);
    painter.drawLine(0,0,0,300);
    painter.drawLine(0,0,300,0);
    painter.drawLine(300,0,300,300);
    painter.drawLine(0,300,300,300);


    pen.setStyle(Qt::DotLine);
    pen.setColor(QColor(255,0,0,255));
    painter.setPen(pen);



    int q=0,w=0,x=0,y=0;
    j=1;
    while(j<10)
    {
        q=q+30;
        x=x+30;
        painter.drawLine(q,w,x,300);
        j++;
    }
    q=0,w=0,x=0,j=0;
    while(j<10)
    {
        y=y+30;w=w+30;
        painter.drawLine(q,w,300,y);
        j++;
    }
  for(j=0;j<10;j++)painter.drawLine(30*j,m[j],30*j+30,m[j+1]);
}

